package com.imooc.utils;

import com.imooc.enums.CodeEnum;

/**
 * @author 丁富民
 * @date 2018/8/17 09:48
 */
public class EnumUtil {

    public static <E, T extends CodeEnum> T getByCode(E code, Class<T> enumClass) {
        for (T each : enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }
}
